package com.initialize.gateway;

import cn.hutool.core.util.NetUtil;
import lombok.extern.slf4j.Slf4j;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;

/**
 * Created with IntelliJ IDEA.
 * User: jane
 * Date: 2019/12/24
 * Time: 10:47 下午
 * Description: 网关启动类
 * @author jane
 */
@Slf4j
//@EnableWebSecurity
@MapperScan("com.initialize.common.mybatis.plus")
@SpringBootApplication(scanBasePackages = "com.initialize")
public class GatewayApplication {

    public static void main(String[] args) {
        int port = 8010;
        int maxPort = port + 10;

        while (!NetUtil.isUsableLocalPort(port)) {
            if (port > maxPort) {
                log.error("端口超出范围");
            }
            port++;
            log.error("端口占用->>{}", port);
        }

        new SpringApplicationBuilder(GatewayApplication.class).
                properties("server.port=" + port).run(args);
    }

}
